package servlet;


/**
 * @description:
 * @author: hank
 * @create: 2021-05-15 22:32
 **/

import DBC.DatabaseConnection;
import Factory.DAOFactory;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/joinGroupServlet")
public class joinGroupServlet extends HttpServlet {
    private final DatabaseConnection dbc = new DatabaseConnection();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setHeader("Access-Control-Allow-Origin","*");
        response.setHeader("Access-Control-Allow-Headers", "X-Requested-With");
        response.setHeader("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
        response.setHeader("Content-Type","text/html;charset=utf-8");
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        try {
            DAOFactory.GroupInstance(this.dbc.getConn()).joinGroup();
        } catch (SQLException troubles) {
            troubles.printStackTrace();
        }
    }
}
